package o;

import android.app.Activity;
import com.huawei.appgallery.agwebview.view.WebViewActivity;
import java.lang.ref.WeakReference;
import java.util.ArrayList;

public class bba {
    private static bba ॱ;
    private ArrayList<WeakReference<WebViewActivity>> ˏ = new ArrayList();

    public static synchronized bba ॱ() {
        bba o_bba;
        synchronized (bba.class) {
            if (ॱ == null) {
                ॱ = new bba();
            }
            o_bba = ॱ;
        }
        return o_bba;
    }

    public void ˎ(WebViewActivity webViewActivity) {
        if (this.ˏ.size() >= 10) {
            Logger.ˎ("WebViewActivityControll", "ready to remove activity.");
            Activity activity = (Activity) ((WeakReference) this.ˏ.get(0)).get();
            if (activity != null) {
                activity.finish();
            }
            this.ˏ.remove(0);
        }
        this.ˏ.add(new WeakReference(webViewActivity));
    }

    public void ˊ(WebViewActivity webViewActivity) {
        int ˏ = ˏ(webViewActivity);
        if (ˏ != -1) {
            this.ˏ.remove(ˏ);
        }
    }

    private int ˏ(WebViewActivity webViewActivity) {
        int size = this.ˏ.size();
        for (int i = 0; i < size; i++) {
            if (((Activity) ((WeakReference) this.ˏ.get(i)).get()) == webViewActivity) {
                return i;
            }
        }
        return -1;
    }
}
